
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <title>Egret</title>
    <meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="full-screen" content="true"/>
    <meta name="screen-orientation" content="portrait"/>
    <meta name="x5-fullscreen" content="true"/>
    <meta name="360-fullscreen" content="true"/>
    <style>
        html, body {
            -ms-touch-action: none;
            background: #FFFFFF;
            padding: 0;
            border: 0;
            margin: 0;
            height: 100%;
        }
		.egret-player{
		    background: #888888;
		}
		td{
		padding:0;
		margin:0;
		width:100px;
		height:100px;
		text-align: center;
		font-size: 12px;

		}
		table{
		border:1px solid #000;
		}
		.title{
		box-sizing: border-box;
		border:2px solid #000;
		border-bottom:none;
		text-align: center;
		font-size: 12px;
		}
		.comment{
		box-sizing: border-box;
		border:2px solid #000;
		border-top:none;
		text-align: center;
		font-size: 12px;
		}
		.enter,.enterColor{
		display: inline-block;
		border: 1px solid #000;
		padding:5px 10px;
		}
		.text{
			text-align: center;
			border:none;
			margin:0;
			padding:0;
		}

		
    </style>

    <!--这个标签为通过egret提供的第三方库的方式生成的 javascript 文件-->
    <!--modules_files_start-->
	<script egret="lib" src="libs/modules/egret/egret.min.js"></script>
	<script egret="lib" src="libs/modules/egret/egret.web.min.js"></script>
	<script egret="lib" src="libs/modules/res/res.min.js"></script>
	<!--modules_files_end-->

    <!--这个标签为不通过egret提供的第三方库的方式使用的 javascript 文件，请将这些文件放在libs下，但不要放在modules下面。-->
    <!--other_libs_files_start-->
		<!-- shortcut start-->
		<script type="text/javascript" src="resource/shortcut/shortcut.js"></script>
		<!-- shortcut end-->
    <!--other_libs_files_end-->

    <!--这个标签会被替换为项目中所有的 javascript 文件-->
    <!--game_files_start-->
	<script src="main.min.js"></script>
	<!--game_files_end-->

	<!--jquery start -->
	<script src="jquery-1.7.2.min.js"></script>
	
	
</head>
<body>
	<input  type="button" value="zoom in" onclick="zoom_in(2)"/>
	<input  type="button" value="zoom out" onclick="zoom_in(0.5)"/>
	<input  type="button" value="zoom fit" onclick="zoom_fit()"/>
	<input  type="button" value="reset view" onclick="reset_view()"/>
	<input  type="button" value="move up" onclick="move(0,-1,0,0)"/>
	<input  type="button" value="move down" onclick="move(0,1,0)"/>
	<input  type="button" value="move left" onclick="move(-1,0,0,0)"/>
	<input  type="button" value="move right" onclick="move(1,0,0,0)"/>
	<input  type="button" value="prev page" onclick="next_page(-1)"/>
	<input  type="button" value="next page" onclick="next_page(1)"/>
	<input  type="button" value="change color" onclick="change_color(Math.random()%256,100,0)"/>
	<input  type="button" value="change text" onclick="change_text('会议名称得分abcdlmnop')"/>
	<input  type="button" value="change text font" onclick="change_text_font('方正硬笔楷书简')"/>
	<input  type="button" value="change text size" onclick="change_text_size(Math.random()%50+30)"/>
	<input  type="button" value="change char space" onclick="change_cs(0.5)"/>
	<input  type="button" value="change line space" onclick="change_ls(0.9)"/>
	<input  type="button" value="up" onclick="move_up_down(true)"/>
	<input  type="button" value="down" onclick="move_up_down(false)"/>
	<input  type="button" value="change alpha" onclick="change_aplha(Math.random()%1)"/>
	<input  type="button" value="SetPos" onclick="set_obj_pos()"/>
	<input  type="button" value="delete obj" onclick="delete_obj()"/>
	<input  type="button" value="select tgnode" onclick="select_tgnode(4)"/>
	<input  type="button" value="insert graph" onclick="insert_graph()"/>
	<input  type="button" value="insert image" onclick="insert_image()"/>
	<input  type="button" value="replace image" onclick="replace_image()"/>
	<input  type="button" value="lock" onclick="lock()"/>
	<input  type="button" value="unlock" onclick="unlock()"/>
	<input  type="button" value="fullfill" onclick="fullfill()"/>
	<input  type="button" value="Add Text" onclick="insert_text()"/>
	<input  type="button" value="AddTxtHead" onclick="insert_textHead()"/>
	<input  type="button" value="DelTxtHead" onclick="del_textHead()"/>
	<input  type="button" value="save" onclick="save()"/>
	<input  type="button" value="selectOptional" onclick="selectOptional()"/>
	<input  type="button" value="文字放大" onclick="change_fontSize(2)"/>
	<input  type="button" value="文字缩小" onclick="change_fontSize(0.5)"/>
	<!--添加创建表格的按钮-->
	<input  type="button" value="table" onclick="insert_table()"/>
	<input  type="button" value="TableBorder" onclick="chgTableBorderStyle()"/>
	<input  type="button" value="TableSize" onclick="chgTableSize()"/>
	<input  type="button" value="TableBColor" onclick="chgTableBorderColor(Math.random()*256,Math.random()*256,Math.random()*256)"/>
	<input  type="button" value="TableRowColor" onclick="chgTableRowColor(Math.random()*256,Math.random()*256,Math.random()*256)"/>
	<input  type="button" value="TableColColor" onclick="chgTableColColor(Math.random()*256,Math.random()*256,Math.random()*256)"/>	
	<input  type="button" value="TableRowH" onclick="chgTableRowH(Math.floor(Math.random()*100)+50)"/>
	<input  type="button" value="TableBWidth" onclick="chgTableBorderWidth(Math.floor(Math.random()*10))"/>
	<input  type="button" value="TableColW" onclick="chgTableColWidth()"/>

	<!--添加修改表格内容的按钮-->
	<input  type="button" value="change table value" onclick="change_table_value()"/>
	<!--添加修改表格图片大小的按钮-->
	<input  type="button" value="change table imageSize" onclick="change_table_imageSize(0.1)"/>
	<!--添加修改单元格内容对齐方式按钮-->
	<input  type="button" value="change table align" onclick="change_table_align()"/>
	<!--添加修改单元格颜色按钮-->
	<input  type="button" value="change table color" onclick="change_table_color()"/>
	<!--添加增加或者删除行或者列(行代表1列代表-1)-->
	<input  type="button" value="add" onclick="add_table(1,200)"/>
	<!--添加删除表格所有的竖线的按钮(横线代表1竖线代表-1)-->
	<input  type="button" value="delete table line" onclick="delete_table_line(-1)"/>
	<!--重置按钮-->
	<input  type="button" value="reset" onclick="reset()"/>
	<!--清除选中-->
	<input  type="button" value="清除选中对象" onclick="clearSelectObj()"/>

	<input  type="button" value="关联对象" onclick="do_objLink(true)"/>
	<input  type="button" value="解除关联" onclick="do_objLink(false)"/>
	<input  type="button" value="check" onclick="check(['微软雅黑','宋体'])"/>




    <div style="position: relative;margin: auto;width: 80%;height: 80%;" class="egret-player"
         data-entry-class="Main"
         data-orientation="auto"
         data-scale-mode="showAll"
         data-resolution-mode="retina"
         data-frame-rate="30"
         data-content-width="1300"
         data-content-height="1300"
         data-show-paint-rect="false"
         data-multi-fingered="2"
         data-show-fps="false" data-show-log="false"
         data-log-filter="" data-show-fps-style="x:0,y:0,size:30,textColor:0x00c200,bgAlpha:0.9">


		<!--弹出的对应的单元格内容的对齐方式-->
		<div class="table_align" style="background: #FFFFFF;display:none;z-index:10;width:270px;height: auto;position: absolute;top: 5%;right: 10%;">
		水平方向的对齐方式
		<select class="align">
			<option value="1">左对齐</option>
			<option value="2" selected = "selected">水平居中对齐</option>
			<option value="3">右对齐</option>
		</select>
		<br />
		垂直方向的对齐方式
		<select class="valign">
			<option value="1">上对齐</option>
			<option value="2" selected = "selected">垂直居中对齐</option>
			<option value="3">下对齐</option>
		</select>
		</div>


		<!--弹出修改表格背景颜色方式的弹出框-->
		<div class="changeColor" style="background: #FFFFFF;z-index:10;display:none;width:270px;height: auto;position: absolute;top: 20%;right: 10%;">
			<select class="changeColor_col">
				<option value="0">所有行</option>
			</select>
			<select class="changeColor_row">
				<option value="0">所有列</option>
			</select>
			<br />
			输入修改的颜色:<input type="text" value="橙色" readonly = readonly>
			<span class="enterColor">确认</span>
		</div>


		<!--弹出对应的表格-->
		<div class="changeValue" style="background:#fff;display:none;z-index:10;width:250px;height: auto;position: absolute;top: 5%;left: 10%;">
			选择行还是列
			<select class="selectCol_or_row">
			<option value="0">行</option>
			<option value="1">列</option>
		 </select>
			<br />
			<br />
			选择对应修改的的行列
			<select class="change">
				
			</select>
		<br />
		<br />
		输入的最大宽度为<span class="maxWidth"></span>:
			<input class="changeTableValue" type="number" min="10">
			<br />
			<br />
		<div class="title"></div>
		<table border="1" cellspacing="0" cellpadding="0">
		</table>
		<div class="comment"></div>
			<br />
		<span class="enter">确认</span>
		</div>
    	</div>
    	<script>
//---------test start---------
// 记录选中对象
var g_v = {};
g_v.select_obj = null;
g_v.scale = 1;
g_v.centerX = 0.5;
g_v.centerY = 0.5;


//x>0为左移,x<0为右移
//Y>0为上移,Y<0为下移
function move(x,y){
	if(x>0) g_v.centerX-=0.1;
	else if(x<0) g_v.centerX+=0.1;
 	if(y>0) g_v.centerY-=0.1;
	else if(y<0) g_v.centerY+=0.1;
	//fireEvent的功能为发送对用的消息(每个不同操作对应的唯一标识),传入对应的x,y值,则对应的对象会有相应的表现
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_VIEW_WINDOW_MOVE,g_v.centerX,g_v.centerY);
}
function zoom_in(f){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_VIEW_WINDOW_ZOOM,f>=1?1:-1);
}
function zoom_fit(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_VIEW_WINDOW_ZOOM_FIT);
}
function reset_view(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_VIEW_WINDOW_RESET);
}
function next_page(next){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_PAGE_NEXT, next);
}

//重置所有
function reset(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_RESET);
}

//清除所有选中样式
function clearSelectObj(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CLEARSELECTOBJ);
}

//文字缩放的点击事件
function change_fontSize(f){
	//获取选中的对象
	var obj = g_v.select_obj;
	//获取的对象是否存在且为文字对象,如果没有的话就return
	if (!obj || obj.ct != GCJ_CLASS_TYPE.CLASS_TYPE_TextExtObj) {
		return;
	}
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_FONTSIZE,f>=1?1:-1);
}


/*
＊ 创建表格
*/
function insert_table(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_INSERT_TABLE);
}

/*
＊ 修改表格的内容
//修改表格内容的点击事件
*/
function change_table_value() {
//获取表格的内核对象(tableobj)
	var obj = g_v.select_obj;
	//判断canvas中是否有表格对象,如果没有的话就return
	if (!obj || obj.ct != GCJ_CLASS_TYPE.CLASS_TYPE_TableObj) {
		return;
	}
	//获取内核对象中的行列数据
	var w = obj.pos.w/3;
	var h = obj.pos.h/3 - obj.title.pos.h - obj.comment.pos.h;
	var col = obj.col;
	var row = obj.row;
	//设置表格的宽高,以及样式
	$("table").width(w).height(h);
	$(".title").width(w).height(obj.title.pos.h/2).css({"line-height":obj.title.pos.h/2+"px"});
	$(".comment").width(w).height(obj.comment.pos.h/2).css({"line-height":obj.comment.pos.h/2+"px"});
	//动态创建单元格
	$("table").html("");
	for (var i = 0; i < col.length; i++) {
		var tr = $("<tr class='otr'>");
		for (var j = 0; j < row.length; j++) {
			var td = $("<td class='otd'>");
			tr.append(td);
			td.css({height: col[i] * $("table").height() / 100, width: $("table").width() * row[j] / 100});
		}
		$("table").append(tr);
	}
	getselect();

	//当改变select的值时,对应的行列要改变
	$(".selectCol_or_row").change(function () {
		getselect();
	})
	//获取界面的select值
	function getselect() {
		var select1 = $(".selectCol_or_row").val();
		if (select1 == 0) {
			$(".change").html("");
			//选择行
			for (var i = 0; i < col.length; i++) {
				var option = $("<option>");
				option.val(i);
				option.html("第" + (i + 1) + "行");
				$(".change").append(option);
			}
		} else if (select1 == 1) {
			$(".change").html("");
			//选择列
			for (var j = 0; j < row.length; j++) {
				var option = $("<option>");
				option.val(j);
				option.html("第" + (j + 1) + "列");
				$(".change").append(option);
			}
		}
		//不调取之前也要获取他的最大宽度
		changeMax(select1);
		$(".change").change(function () {
			changeMax(select1);
		})
	}

	//对应的选择第几行或者第几列 宽度最多能修改的值
	function changeMax( select1) {
		var value = $(".change").val();
		if (select1 == 0) {
			if (value == $(".change option").length - 1) {
				$(".changeTableValue").attr("max",col[value]*1 + col[value * 1 - 1])
				$(".maxWidth").html(col[value] + col[value * 1 - 1]);
			} else {
				$(".changeTableValue").attr("max",col[value]*1 + col[value * 1 + 1]);
				$(".maxWidth").html(col[value]*1 + col[value * 1 + 1]);
			}
		} else if (select1 == 1) {
			if (value == $(".change option").length - 1) {
				$(".changeTableValue").attr("max",row[value]*1 + row[value * 1 - 1]);
				$(".maxWidth").html(row[value]*1 + row[value * 1 - 1]);
			} else {
				$(".changeTableValue").attr("max",row[value]*1 + row[value * 1 + 1])
				$(".maxWidth").html(row[value]*1 + row[value * 1 + 1]);
			}
		}
	}

//发送消息获取内核数据将数据返回到表格中
	var cellContent = obj.getCellContent();
	var UItableObj = new UITableObj();

	//将表格的内容复制到弹出框中
	UItableObj.copyCellContent(cellContent);
	//将抬头和备注赋值到弹出框中
	$(".title").html(obj.title.te);
	$(".comment").html(obj.comment.te);
	//表格的div显示
	$(".changeValue").show();


	//对应表格点击事件会对其做相应的内容修改
	$("td,.title,.comment").click(function (event) {
		//td中已经有了input,则不需要响应点击事件
		if ($(this).children("input").length > 0) {
			return false;
		}
		var tdObj = $(this);
		var preText = tdObj.html();
		//得到当前文本内容
		var inputObj = $("<input class='text' type='text' />");
		//创建一个文本框元素
		tdObj.html(""); //清空td中的所有元素
		inputObj.width(tdObj.width()).height(tdObj.height()).css({
			border: "none",
			font: "微软雅黑"
		}).val(preText).appendTo(tdObj).trigger("select");
		//已进入编辑状态后，不再处理click事件
		inputObj.click(function () {
			return false;
		});
	});
	


	//确认的点击事件
		$(".enter").click(function () {
			//获取表格的内容
			var teblecontent = [];
			//获取其他input框的值
			//行还是列
			var select_col_or_row = $(".selectCol_or_row").val();
			//第几行或第几列
			var change_col_or_row = $(".change").val();
			//改变的值
			var col_or_row_number = $(".changeTableValue").val();
			//获取td中的内容
			var tr = $(".otr");
			for (var i = 0; i < tr.length; i++) {
				var td = tr.eq(i).find(".otd");
				var arr = [];
				for (var j = 0; j < td.length; j++) {
					if (td.eq(j).find("input").length) {
						arr.push(td.eq(j).find("input").val());
					} else {
						arr.push(td.eq(j).html());
					}
				}
				teblecontent.push(arr);
			}

			//获取title和comment的内容
			var title = $(".title").html();
			if($(".title").find("input").length){
				title =$(".title") .find("input").val();
			}
			var comment = $(".comment").html();
			if($(".comment").find("input").length){
				comment =$(".comment") .find("input").val();
			}

			//发送对应的消息
			//发送修改表格内容的消息(对应的消息以及对应的每行每列的内容)
			GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_SET_TABLE_CONTENT, teblecontent,title,comment);
			//发送修改行列宽高的方法
			if(col_or_row_number.length != 0){
				GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_COL_OR_ROW, select_col_or_row, change_col_or_row, col_or_row_number);
			}
			$(".changeValue").hide();
	//调用两个消息(一个消息是修改行列的宽度,一个消息是修改textextobj中的内容)
		})
	}

	//修改表格图片大小
	function change_table_imageSize(size){
		//获取表格的内核对象(tableobj)
		var obj = g_v.select_obj;
		//判断canvas中是否有表格对象,如果没有的话就return
		if (!obj || obj.ct != GCJ_CLASS_TYPE.CLASS_TYPE_TableObj) {
			return;
		}
		GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_IMAGESIZE, size);

	}

	//修改单元格中内容的对齐方式
	function change_table_align(){
		//获取表格的内核对象(tableobj)
		var obj = g_v.select_obj;
		var align = null;
		var valign = null;
		//判断canvas中是否有表格对象,如果没有的话就return
		if (!obj || obj.ct != GCJ_CLASS_TYPE.CLASS_TYPE_TableObj) {
			return;
		}
		$(".table_align").show();
		$(".align").change(function(){
			align = $(".align").val();
			GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_ALIGN,align,valign);
		})
		$(".valign").change(function(){
			valign = $(".valign").val();
			GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_ALIGN,align,valign);
		})

	}

/*
* 修改单元格的背景颜色
* */
function change_table_color(){
	//获取表格的内核对象(tableobj)
	var obj = g_v.select_obj;
	//判断canvas中是否有表格对象,如果没有的话就return
	if (!obj || obj.ct != GCJ_CLASS_TYPE.CLASS_TYPE_TableObj) {
		return;
	}
	//行
	$(".changeColor").show();
	//新清除select中所有的子元素
	$(".changeColor_col,.changeColor_row").html("");
	//所有行
	var option = $("<option>");
	option.val(0);
	option.html("所有行");
	$(".changeColor_col").append(option);
	//所有列
	var option = $("<option>");
	option.val(0);
	option.html("所有列");
	$(".changeColor_row").append(option);
	//动态创建option
	for(var i =0;i<obj.cell.length;i++){
		var option = $("<option>");
		option.val(i+1);
		option.html("第" + (i + 1) + "行");
		$(".changeColor_col").append(option);
	}
	//列
	for(var j =0;j<obj.cell.length;j++){
		var option = $("<option>");
		option.val(j+1);
		option.html("第" + (j + 1) + "列");
		$(".changeColor_row").append(option);
	}


	//确认的点击事件
	$(".enterColor").click(function(){
		var cell_col = $(".changeColor_col").val();
		var cell_row = $(".changeColor_row").val();
		GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_COLOR,cell_col,cell_row);
		$(".changeColor").hide();
	})

}

/*
* 删除表格所有的横线或者竖线
* 1 代表横线  -1 代表竖线
* */
function delete_table_line(type){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_DELETE_TABLE_LINE, type);
}


/*
* 新增表格的行或者列
* */
function add_table(type,size){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_ADD_TABLE, type,size);
}
/*
＊ 修改颜色
* 参数：r:红色,范围[0,255]
* 参数：g:红色,范围[0,255]
* 参数：b:红色,范围[0,255]
*/
function change_color(r,g,b){
	var color = FColor.from(r,g,b);
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_COLOR_SETTING, color);
}
/*
＊ 修改文字
* 参数：text:文字内容
*/
function change_text(text){
	var obj = g_v.select_obj;
	if(!obj || obj.ct  != GCJ_CLASS_TYPE.CLASS_TYPE_TextExtObj){
		return ;
	}

	var fs = obj.style.copy();
	
	
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_TEXT_INSERT_UPDATE, text, fs);
}

/*
＊ 修改字间距
* 参数：cs_f:字间距，放大倍数,例如：1.5
*/
function change_cs(cs_f){
	var obj = g_v.select_obj;
	if(!obj || obj.ct  != GCJ_CLASS_TYPE.CLASS_TYPE_TextExtObj){
		return ;
	}

	var fs = obj.style.copy();
	fs.cs = 2*fs.fs*cs_f;
	var text = obj.te;
	
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_TEXT_INSERT_UPDATE, text, fs);
}
/*
＊ 修改行间距
* 参数：ls_f:行间距，放大倍数,例如：1.5
*/
function change_ls(ls_f){
	var obj = g_v.select_obj;
	if(!obj || obj.ct  != GCJ_CLASS_TYPE.CLASS_TYPE_TextExtObj){
		return ;
	}

	var fs = obj.style.copy();
	fs.ls = fs.fs*ls_f;
	var text = obj.te;
	
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_TEXT_INSERT_UPDATE, text, fs);
}
/*
＊ 修改字体
* 参数：font:字体名称
*/
function change_text_font(font){
	var obj = g_v.select_obj;
	if(!obj || 
		(obj.ct!=GCJ_CLASS_TYPE.CLASS_TYPE_TextExtObj 
		&& obj.ct!=GCJ_CLASS_TYPE.CLASS_TYPE_TableExtObj
		&& obj.ct!=GCJ_CLASS_TYPE.CLASS_TYPE_TableRowObj
		&& obj.ct!=GCJ_CLASS_TYPE.CLASS_TYPE_TableCellObj)){
		return ;
	}

	if(obj.ct==GCJ_CLASS_TYPE.CLASS_TYPE_TableRowObj) {
		obj=obj.children[0].children[0];
	}else if(obj.ct==GCJ_CLASS_TYPE.CLASS_TYPE_TableCellObj) {
		obj=obj.children[0];
	}else if(obj.ct==GCJ_CLASS_TYPE.CLASS_TYPE_TableExtObj) {
		obj=obj.children[0].children[0].children[0];
	}

	var fs = obj.style.copy();
	fs.fn = font;
	var text = obj.te;
	
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_TEXT_INSERT_UPDATE, text, fs);
}
/*
＊ 修改字号
* 参数：size:字号
*/
function change_text_size(size){
	var obj = g_v.select_obj;
	if(!obj || obj.ct  != GCJ_CLASS_TYPE.CLASS_TYPE_TextExtObj){
		return ;
	}
	var fs = obj.style.copy();
	fs.fs = size;
	var text = obj.te;
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_TEXT_INSERT_UPDATE, text, fs);
}

/* 
* 上下移动
* 参数：up:true表示上移，false表示下移动
*/
function move_up_down(up){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_MOVE_UP_DOWN, up);
}
/* 
* 修改透明度
* 参数：alpha_f:范围[0,1.0]
*/
function change_aplha(alpha_f){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_ALPHA_SETTING, alpha_f);
}

function set_obj_pos() {
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_POSITION_SET,20,10);
}
/* 
* 删除选中对象
*/
function delete_obj(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_OBJ_DELETE);
}
/* 
* 选中题纲节点
*/
function select_tgnode(obj_id){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_SELECT_TGNODE, obj_id);
}
/* 
* 插入图形
*/
function insert_graph(){
	var cp = CommonUtil.createBasicCompoundPath(CommonUtil.COMPOUNDPATH_SIX).toJson();
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_GRAPH_INSERT, cp, {x:0.5,y:0.5});
}
/* 
* 插入图片
*/
function insert_image(){
	var source = 'http://itbour-generate.img-cn-hangzhou.aliyuncs.com/image/U10/2016/09/22/161121182_6SMbTjIIz6c1AJ0KEZos/0.jpg';
	source = 'http://itbour-back.oss-cn-hangzhou.aliyuncs.com/image/U2/2017/05/26/165732733_OIIuA4Gf1tfoqXnCK5IW.jpg';
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_IMAGE_INSERT, source, {x:0.5,y:0.5});
}

/* 
* 替换图片
*/
function replace_image(){
	var source = 'http://itbour-generate.img-cn-hangzhou.aliyuncs.com/image/U10/2016/09/22/161121182_6SMbTjIIz6c1AJ0KEZos/1.jpg';
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_IMAGE_INSERT, source, {x:0.5,y:0.5});
}

/* 
* 锁定
*/
function lock(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_LOCK);
}

/* 
* 全部解除锁定
*/
function unlock(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_UNLOCK_ALL);
}
/* 
* 铺满
*/
function fullfill(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_FULL_FILL);
}
/* 
* 新建文字
*/
function insert_text(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_TEXT_INSERT_UPDATE,null,null);
}
function insert_textHead(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_TEXT_EX_INSERT_HEAD,
		g_v.select_obj.id,null,null,-2,0,null);
}
function del_textHead(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_TEXT_EX_DELETE_HEAD,g_v.select_obj.id);
}

function do_objLink(b) {
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_SET_OBJ_LINK,b);
}


function check(fontSizeList){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHECK_OBJ,fontSizeList,false,function(Vert){
		console.log(Vert);
	});
}

/* 
* 保存
*/
function save(){
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_SAVE_TEMPLATE_DATA);
}

/* 
* 保存
*/
var select = true;
function selectOptional(){
	select = !select;
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_SELECT_OPTIONAL_TGNODE,25,select);
}

/*
* 改变table边框样式
*/
var g_table_style=1;
function chgTableBorderStyle() {
	g_table_style++;
	if(g_table_style>8) {
		g_table_style=1;
	}
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_BORDER_STYLE,g_table_style);
}

function chgTableSize() {
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_ROW_COL_SIZE,4,3);
}

function chgTableBorderColor(r,g,b) {
	var color = FColor.from(r,g,b);
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_BORDER_COLOR,color);
}
function chgTableRowColor(r,g,b) {
	var color = FColor.from(r,g,b);
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_ROW_COL_COLOR,1,color);
}

function chgTableColColor(r,g,b) {
	var color = FColor.from(r,g,b);
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_ROW_COL_COLOR,2,color);
}


function chgTableRowH(h) {
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_ROW_HEIGHT,h);
}

function chgTableBorderWidth(w) {
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_BORDER_WIDTH,w);
}

function chgTableColWidth() {
	GlobalData.messager().fireEvent(MESSAGE.MSG_UI2KRL_CHANGE_TABLE_COL_WIDTH,[3,4,5]);
	
}

GlobalData.messager().register(
		MESSAGE.MSG_KRL2UI_VIEW_WINDOW_RESET_FINISH,
		function(){
			console.log('reset view finish!');
			g_v.scale = 1;
			g_v.centerX = 0.5;
			g_v.centerY = 0.5;
		},
		this);
GlobalData.messager().register(
		MESSAGE.MSG_KRL2UI_VIEW_WINDOW_ZOOM_FINISH,
		function(scale, centerX, centerY){
			console.log('zoom view finish! '+scale+':'+centerX+':'+centerY);
			g_v.scale = scale;
			g_v.centerX = centerX;
			g_v.centerY = centerY;
		},
		this);
GlobalData.messager().register(
		MESSAGE.MSG_KRL2UI_VIEW_WINDOW_MOVE_FINISH,
		function(scale, centerX, centerY){
			console.log('move view finish! '+scale+':'+centerX+':'+centerY);
			g_v.scale = scale;
			g_v.centerX = centerX;
			g_v.centerY = centerY;
		},
		this);

GlobalData.messager().register(
		MESSAGE.MSG_KRL2UI_PAGE_NEXT_FINISH,
		function(pageInfo, topics){
			console.log('switch page  finish! '+JSON.stringify(pageInfo)+' '+JSON.stringify(topics));
			/* pageInfo包含以下属性
			 *      sjgPageCount：SJGPage的总页数
			 *      sjgPageIndex：SJGPage的下标
			 *      pageContentCount：当前页的pageContent的个数
			 *      pageContentIndex：当前pageContent在当前页中的偏移
			 */
			var str = (''+(pageInfo.sjgPageIndex+1)+'/'+pageInfo.sjgPageCount+' 页')+(pageInfo.pageContentCount==1?'':(',情况'+(pageInfo.pageContentIndex+1)));
			console.log(str);
		},
		this);
GlobalData.messager().register(
		MESSAGE.MSG_UI2KRL_TEMPLATE_DATA_RENDER_COMPLETE,
		function(pageInfo, topics){
			console.log('switch page  finish! '+JSON.stringify(pageInfo)+' '+JSON.stringify(topics));
			var str = (''+(pageInfo.sjgPageIndex+1)+'/'+pageInfo.sjgPageCount+' 页')+(pageInfo.pageContentCount==1?'':(',情况'+(pageInfo.pageContentIndex+1)));
			console.log(str);
		},
		this);




GlobalData.messager().register(
		MESSAGE.MSG_UI_OBJ_SELECTED,
		function(objs){
			if(objs.length<1){
				// 当作未选中处理
				console.log('select : 未选中');
				g_v.select_obj = null; // 清除选中
			}else{
				var obj = objs[0];
				g_v.select_obj = obj; // 记录选中
				var pt = obj.pointToStagePercentage();
				console.log(pt.x, pt.y,pt.w,pt.h);
				if(obj.ct == GCJ_CLASS_TYPE.CLASS_TYPE_TextExtObj){
					// 如果是文字
					console.log('select : 文字');

				}else if(obj.ct == GCJ_CLASS_TYPE.CLASS_TYPE_ImageObj){
					// 如果是图片
					console.log('select : 图片');
				}else if(obj.ct == GCJ_CLASS_TYPE.CLASS_TYPE_GraphObj){
					// 如果是图形
					console.log('select : 图形');
				}else if(obj.ct == GCJ_CLASS_TYPE.CLASS_TYPE_TableExtObj){
					// 如果是表格
					console.log('select : 表格');
				}else if(obj.ct == GCJ_CLASS_TYPE.CLASS_TYPE_TableRowObj){
					// 如果是表格行
					console.log('select : 表格行');
				}else if(obj.ct == GCJ_CLASS_TYPE.CLASS_TYPE_TableCellObj){
					// 如果是表格单元格
					console.log('select : 表格单元格');
				}
			}
		},
		this);



//---------设置canvas内容区的大小 start---------
				var DEFAULT_SIZE = 1400;
                var div = $('.egret-player');
                var w = div.width();
                var h = div.height();
                var dw= DEFAULT_SIZE, dh=DEFAULT_SIZE;
                if(w/h>1){
                    dw = dh*w/h;
                }else{
                    dh= dw*h/w;
                }
                div.attr('data-content-width', dw);
                div.attr('data-content-height', dh);
                DEFINE.DEFAULT_CANVAS_WITH = dw;
                DEFINE.DEFAULT_CANVAS_HEIGHT = dh;

//                DEFINE.DEFAULT_CANVAS_WITH = 1400;
//                DEFINE.DEFAULT_CANVAS_HEIGHT = 1400;
//---------设置canvas内容区的大小 end---------



//---------设置 调试信息---------
// “微调”编辑器模式
DEFINE.WORK_mode=DEFINE.WORK_MODE_1;
DEFINE.SELECT_CONTROL_mode=DEFINE.SELECT_CONTROL_MODE_1; // 控制点设置为只有右下角，且为圆，且拖动控制点不需要保持宽高比
DEFINE.RES_LIST.RIGHT_BOTTOM_CONTROL='http://192.168.31.27:3001/control.png';
DEFINE.APP_SERVER_URL= "http://192.168.31.252:3000";  // app服务地址
DEFINE.EDITOR_uId=2;
//DEFINE.EDITOR_docId=2109;
//DEFINE.EDITOR_dId=762;//715



// “模版／设计”编辑器模式:展架图的情况下：
//DEFINE.PRINTING_BLEEDING=3;
//DEFINE.DISPLAY_RACK_RECT = true; // 显示60x160的框框
//DEFINE.DEFAULT_TEMPLATE_PAGE_WITH = 754;
//DEFINE.DEFAULT_TEMPLATE_PAGE_HEIGHT = 1690;



//---------设置 调试信息 end---------

//---------shortcut start---------
shortcut.isADown=false;
shortcut.add("A",function() { shortcut.isADown=true;},{'type':'keydown','propagate':true,'target':document});
//keyup of ctrl in mac is invalid.//
shortcut.add("A",function() { shortcut.isADown=false;},{'type':'keyup','propagate':true,'target':document});
egret.isADown=function(){ return shortcut.isADown;};
egret.setADown=function(d){shortcut.isADown=d;}


shortcut.isSDown=false;
shortcut.add("S",function() { shortcut.isSDown=true;},{'type':'keydown','propagate':true,'target':document});
//keyup of ctrl in mac is invalid.//
shortcut.add("S",function() { shortcut.isSDown=false;},{'type':'keyup','propagate':true,'target':document});
egret.isSDown=function(){ return shortcut.isSDown;};
egret.setSDown=function(d){shortcut.isSDown=d;}

shortcut.isCDown=false;
shortcut.add("C",function() { shortcut.isCDown=true;},{'type':'keydown','propagate':true,'target':document});
//keyup of ctrl in mac is invalid.//
shortcut.add("C",function() { shortcut.isCDown=false;},{'type':'keyup','propagate':true,'target':document});
egret.isCDown=function(){ return shortcut.isCDown;};
egret.setCDown=function(d){shortcut.isCDown=d;}

shortcut.isRDown=false;
shortcut.add("R",function() { shortcut.isRDown=true;},{'type':'keydown','propagate':true,'target':document});
//keyup of ctrl in mac is invalid.//
shortcut.add("R",function() { shortcut.isRDown=false;},{'type':'keyup','propagate':true,'target':document});
egret.isRDown=function(){ return shortcut.isRDown;};
egret.setRDown=function(d){shortcut.isRDown=d;}

shortcut.isSpaceDown=false;
shortcut.add("Space",function() { shortcut.isSpaceDown=true;},{'type':'keydown','propagate':true,'target':document});
//keyup of ctrl in mac is invalid.//
shortcut.add("Space",function() { shortcut.isSpaceDown=false;},{'type':'keyup','propagate':true,'target':document});
egret.isSpaceDown=function(){ return shortcut.isSpaceDown;};
egret.setSpaceDown=function(d){shortcut.isSpaceDown=d;}

//---------shortcut end---------

        egret.runEgret();
    </script>
</body>
</html>
